package o;

import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import androidx.annotation.Nullable;
import o.ah.g;

public class cb {
    private boolean ʽ;
    private boolean ˊ = false;
    private ColorStateList ˋ = null;
    private Mode ˎ = null;
    private boolean ˏ = false;
    private final CompoundButton ॱ;

    public cb(CompoundButton compoundButton) {
        this.ॱ = compoundButton;
    }

    public void ॱ(AttributeSet attributeSet, int i) {
        TypedArray obtainStyledAttributes = this.ॱ.getContext().obtainStyledAttributes(attributeSet, g.ॱꓸ, i, 0);
        try {
            if (obtainStyledAttributes.hasValue(g.ॱᐨ)) {
                int resourceId = obtainStyledAttributes.getResourceId(g.ॱᐨ, 0);
                if (resourceId != 0) {
                    this.ॱ.setButtonDrawable(ar.ˋ(this.ॱ.getContext(), resourceId));
                }
            }
            if (obtainStyledAttributes.hasValue(g.ॱᐧ)) {
                iq.ॱ(this.ॱ, obtainStyledAttributes.getColorStateList(g.ॱᐧ));
            }
            if (obtainStyledAttributes.hasValue(g.ॱᶥ)) {
                iq.ˎ(this.ॱ, cl.ˏ(obtainStyledAttributes.getInt(g.ॱᶥ, -1), null));
            }
            obtainStyledAttributes.recycle();
        } catch (Throwable th) {
            obtainStyledAttributes.recycle();
        }
    }

    public void ˎ(ColorStateList colorStateList) {
        this.ˋ = colorStateList;
        this.ˊ = true;
        ॱ();
    }

    public void ॱ(@Nullable Mode mode) {
        this.ˎ = mode;
        this.ˏ = true;
        ॱ();
    }

    public void ˏ() {
        if (this.ʽ) {
            this.ʽ = false;
            return;
        }
        this.ʽ = true;
        ॱ();
    }

    void ॱ() {
        Drawable ॱ = iq.ॱ(this.ॱ);
        if (ॱ == null) {
            return;
        }
        if (this.ˊ || this.ˏ) {
            ॱ = gg.ʻ(ॱ).mutate();
            if (this.ˊ) {
                gg.ॱ(ॱ, this.ˋ);
            }
            if (this.ˏ) {
                gg.ˋ(ॱ, this.ˎ);
            }
            if (ॱ.isStateful()) {
                ॱ.setState(this.ॱ.getDrawableState());
            }
            this.ॱ.setButtonDrawable(ॱ);
        }
    }

    public int ॱ(int i) {
        if (VERSION.SDK_INT >= 17) {
            return i;
        }
        Drawable ॱ = iq.ॱ(this.ॱ);
        if (ॱ != null) {
            return i + ॱ.getIntrinsicWidth();
        }
        return i;
    }
}
